package com.moli.controller;

import com.moli.domain.ResponseResult;
import com.moli.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author xiaolu
 * @Date 2023/6/8
 * @Description 头像上传控制层
 */
@RestController
public class UploadController {
    @Autowired
    private UploadService uploadService;

    /**
     * 用户上传头像
     * 不能大于1mb
     * @param img
     * @return
     * @throws IOException
     */
    @PostMapping("/upload")
    public ResponseResult uploadImg(MultipartFile img) throws IOException {
        return uploadService.uploadImg(img);
    }
}
